﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EPiServer.Data.Dynamic;
using EPiServer.Personalization.VisitorGroups;
using EPiServer.Web.Mvc.VisitorGroups;
using EPiServer;
using System.Web.Mvc;
using EPiServer.Data;
using System.ComponentModel.DataAnnotations;

namespace CriteriaPack.BandwidthCriterion
{
  
    public class SettingsForBandwidth : CriterionModelBase
    {
        [Required]
        [DojoWidget(SelectionFactoryType = typeof(BandwidthPropertyNameFactory))]
        public string Bandwidth { get; set; }

        public override ICriterionModel Copy()
        {
            return base.ShallowCopy();
        }
    }

    public class BandwidthPropertyNameFactory : ISelectionFactory
    {
        #region ISelectionFactory Members

        public IEnumerable<SelectListItem> GetSelectListItems(Type property)
        {
            yield return new SelectListItem() { Text = "", Value = "" };
            yield return new SelectListItem() { Text = "Up to 384 Kbit/s", Value = "384" };
            yield return new SelectListItem() { Text = "384 Kbit/s to 3 Mbit/s", Value = "3000" };
            yield return new SelectListItem() { Text = "3 to 6 Mbit/s", Value = "6000" };
            yield return new SelectListItem() { Text = "6 to 10 Mbit/s", Value = "10000" };
            yield return new SelectListItem() { Text = "10 to 100 Mbit/s", Value = "100000" };
        }

        #endregion
    }
}
